Skip to content

feat: connect Ollama, vLLM and llama.cpp on the same server - #6

Merged
MattDHill merged 2 commits into
masterfrom
feat/local-model-integrations
Nov 29, 2026
Merged

MattDHill merged 2 commits into
masterfrom
feat/local-model-integrations

Conversation

@MattDHill

Copy link
Copy Markdown
Member

Lets OpenCode use models served by Start9's Ollama, vLLM and llama.cpp packages on the same server, so a fully self-hosted setup needs no outside provider.

How it works

  • Connect Local Models, a new action, lists the backends installed now and stores the chosen ones in store.json. Each becomes an optional running dependency while it is connected and installed.
  • startos/localModels.ts resolves each connected backend's bridge address with .const(), and for vLLM and llama.cpp mounts its public volume onto a new mounts volume, which isn't backed up, to read credentials.json. main.ts hands OpenCode the resulting providers in OPENCODE_CONFIG_CONTENT, a config layer OpenCode merges over the global file. opencode.json is never written. A backend that isn't resolvable is left out, and .const() restarts OpenCode when it appears.
  • Ollama uses OpenCode's built-in Ollama provider (id ollama, settings.baseURL only). That plugin discovers the pulled models every 30 seconds, along with each one's tool and vision support.
  • vLLM gets an OpenAI-compatible provider for the model vLLM publishes as served (credentials.json → model, since vLLM 0.33.0:1). Switching models in vLLM restarts OpenCode onto the new one. Tool calling is set on explicitly: OpenCode's built-in vLLM plugin marks discovered models tool-less, but every vLLM preset serves with a tool-call parser, and config model overrides apply after the plugins.
  • llama.cpp gets one model, llama-cpp/current. llama-server serves a single model and answers whatever model name it is sent.
  • Configure Model Providers refuses the reserved ids ollama, vllm and llama-cpp. Its field example changes from vllm to lab.
  • Version: stays 2.4.1:2, which community-prod has never served. Its release notes become the first release's notes.

Verified on a StartOS 0.4.3 box (x86_64, CPU only)

  • Ollama 0.40.18:0 with qwen3:0.6b: after connecting, OpenCode listed the model with tools: true and a 40,960-token context. A session on ollama/qwen3:0.6b made a write tool call that created the file with the requested content.
  • llama.cpp 12110:1 with its llama-32-1b preset: the key was read from the mounted public volume. A session on llama-cpp/current made a tool call that wrote the file, so llama-server accepts the fixed model name.
  • vLLM 0.34.0:0 (CPU build), custom Qwen/Qwen2.5-0.5B-Instruct with a tool-call parser: OpenCode received the provider with the published key and model and tools: true. vLLM itself never finished starting on this CPU-only box, its own health check failing after 35 minutes, so a real vLLM completion is untested. While vLLM accepted connections without answering, OpenCode's /api/config and /api/model stalled for up to 30 seconds; both returned in about a second once vLLM stopped.
  • Lifecycle:
    • Installing this build over a running one kept the connections.
    • Uninstalling a connected vLLM dropped its provider and its dependency entry, and OpenCode stayed healthy.
    • Unchecking llama.cpp replaced the stored list and removed its provider and dependency.
    • Configure Model Providers refused vllm without writing anything.
  • Checks: tsc and Prettier pass. The two low-severity npm audit findings are fast-xml-parser inside the SDK and also present on master.

review effort: 'xhigh'

model: claude-opus-5-5

🤖 Generated with Claude Code

- Connect Local Models action: opt in to each installed backend; each becomes an optional dependency while connected and installed
- main.ts resolves each backend's bridge address and its public credentials reactively and hands OpenCode the providers in OPENCODE_CONFIG_CONTENT, never in opencode.json
- Ollama goes through OpenCode's built-in Ollama provider for live model discovery; vLLM serves the model it publishes, with tool calling on; llama.cpp is one model that llama-server answers with whatever it serves
- a `mounts` volume, not backed up, holds the backends' mounted public volumes
- Configure Model Providers reserves the ids ollama, vllm and llama-cpp
- README, instructions and release notes cover the integrations

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Three correctness fixes proposed:

  1. P2 — Invalidate disconnected credential mounts (startos/localModels.ts:164). After connecting vLLM or llama.cpp, disconnect it, uninstall/reinstall it, then reconnect at the same bridge address. The disconnected branch skips both address watches and readCredentials, leaving mountedFor unchanged. Reconnection skips the mount and reads the old/empty volume instead of the replacement credentials. The proposal drops the cached entry when disconnected, forcing a remount on reconnection.

  2. P2 — Reject existing provider-ID collisions before saving (startos/actions/connectLocalModels.ts:52). The previous provider action explicitly suggested vllm, so an existing remote provider with that ID is reachable. Connecting local vLLM replaces its effective URL/key but retains the earlier models and default: OpenCode folds same-ID providers rather than replacing them (upstream implementation). Those remote model IDs then target the local server and fail. Reserving future form IDs does not handle existing configuration. The proposal rejects the connection without saving and explains how to rename/remove the old entry, with translated feedback and matching docs.

  3. P2 — Keep incompatible installed backends visible as dependencies (startos/dependencies.ts:20–24). For example, llama.cpp before 11960:1 has no api-key host. It is offered by Connect Local Models, but its missing address makes enabled false, suppressing the very version warning that would explain why no model appears. The proposal checks installed-manifest presence independently of API availability; uninstall still disables the dependency.

The reviewed head merges cleanly with master; all three current CI checks passed. I inspected the published SDK and pinned upstream provider semantics without building or running the change. The proposal is untested; please verify the disconnect/reinstall/reconnect flow, collision rejection, and an older backend's update warning when adopting it.

Proposed changes: 1be68ed...proposal/6

To adopt the proposal, cherry-pick it onto your branch rather than merging or pulling it, so the PR's head stays your own commit:

git fetch https://github.com/Start9-Community/opencode-startos.git proposal/6
git cherry-pick 1be68ed36212da730bcbb109c8315ba89e547fec..FETCH_HEAD

If your branch has moved since 1be68ed36212da730bcbb109c8315ba89e547fec, resolve any conflicts the cherry-pick reports, or apply the changes your own way. Then push and say so in a comment.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white

Copy link
Copy Markdown
Member

Review and proposed fixes are published above; I did not change this PR’s branch. The final-review handoff failed because @MattDHill is both the configured final reviewer and the PR author, so GitHub rejects that review request. This Helix limitation is tracked at https://github.com/Start9Labs/helix-startos-internal/issues/213.

… backends visible

- drop a disconnected backend's cached mount, so reconnecting after a reinstall reads the new credentials
- Connect Local Models refuses a backend whose id is already a provider in opencode.json
- a connected backend counts as a dependency while it is installed, so an incompatible version shows its warning

Co-Authored-By: helix-white <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>

@helix-red helix-red left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The head is unchanged since @helix-white’s review. I independently confirmed its three P2 findings; the existing published proposal addresses them and can be adopted as-is:

  1. Invalidate credential mounts on disconnect — startos/localModels.ts:164. Disconnecting skips the address and credential watches without clearing mountedFor. If the backend is uninstalled/reinstalled while disconnected and returns at the same address, reconnecting reads the obsolete mount rather than the replacement public volume. Clear its cached mount identity on disconnect.
  2. Reject existing provider-ID collisions before saving — startos/actions/connectLocalModels.ts:52. Existing configurations can use vllm (the previous form’s example). OpenCode 2.4.1 overlays same-ID providers, retaining earlier models/settings, so connecting local vLLM redirects those remote models to the local endpoint. Reserving future IDs does not repair existing entries. Reject the connection without saving and explain how to rename/remove the conflicting entry.
  3. Track installed dependencies independently of API availability — startos/dependencies.ts:20–24. A selected older llama.cpp release without the Bearer API host resolves no address, disabling the dependency and hiding its version warning. Use reactive manifest presence for dependency activation; reserve address availability for effective provider generation.

The proposal records these contracts at their production owners and updates the user documentation and translations. I read the full diff, the published SDK 4.1.0 implementations, backend contracts, and the pinned upstream provider overlay/discovery code. The head merges cleanly with master; all three current CI checks passed. No builds or tests were run for this review. The author should verify the proposed disconnect/reinstall/reconnect behavior, collision rejection, and incompatible-backend warning.

Proposed changes: 1be68ed...proposal/6

To adopt the proposal, cherry-pick it onto your branch rather than merging or pulling it, so the PR’s head stays your own commit:

git fetch https://github.com/Start9-Community/opencode-startos.git proposal/6
git cherry-pick 1be68ed36212da730bcbb109c8315ba89e547fec..FETCH_HEAD

If your branch has moved since 1be68ed36212da730bcbb109c8315ba89e547fec, resolve any conflicts the cherry-pick reports, or apply the changes your own way. Then push and say so in a comment.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red

Copy link
Copy Markdown

My review confirms the three existing findings and endorses the published proposal; I did not change the PR branch or replace the proposal. Final-review handoff is still blocked because GitHub cannot request a review from the PR author (@MattDHill), who is also the configured final reviewer. This is already tracked in https://github.com/Start9Labs/helix-startos-internal/issues/213.

@helix-white

Copy link
Copy Markdown
Member

The head remains 1be68ed and still merges cleanly with master. @helix-red confirmed the same three findings, so my existing changes-requested verdict and proposal/6 stand. No further code changes or review requests from me; this is awaiting the author’s response/adoption and verification.

@MattDHill

Copy link
Copy Markdown
Member Author

Adopted proposal/6 as 453f158: cherry-picked unchanged and re-authored. Tested on our box:

  • Collision: with a hand-written llama-cpp provider in opencode.json, connecting llama.cpp failed with the new message. localBackends stayed unset and no dependency was enabled.
  • Reconnect after reinstall:
    • Connecting llama.cpp gave OpenCode the published key (the hashes matched), and disconnecting removed the dependency.
    • Uninstalling and reinstalling llama.cpp minted a new key. Reconnecting gave OpenCode that new key, not the old one, and the service stayed healthy.
  • An older backend's warning: not exercised, since it needs a pre-11960:1 llama.cpp. The check is now the installed manifest's presence, read with .const().

tsc and Prettier pass.

@helix-white helix-white left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three prior findings are resolved. The new head's tree exactly matches proposal/6: disconnect invalidates the credential-mount cache, existing provider-ID collisions fail before saving, and dependency activation watches installed-manifest presence independently of API availability. The contracts, translations and user documentation match the fixes. It merges cleanly with master.

The author reports successful collision-rejection and disconnect/reinstall/reconnect tests, plus passing typecheck and formatting. The older-backend warning and a real vLLM completion remain explicitly untested. Current-head matrix discovery passed; x86 and ARM builds are still running. I ran no builds or tests for this re-review. No remaining blocking findings.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-red helix-red left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three prior findings are resolved. I reviewed the changes since 1be68ed and confirmed this head's tree exactly matches the published proposal: disconnect clears the credential-mount cache, existing provider-ID collisions reject before saving, and installed-manifest presence keeps incompatible connected backends visible independently of API availability. The production contracts, translations and documentation match those fixes.

The head merges cleanly with master; all three current CI checks passed. The author reports successful collision rejection and disconnect/reinstall/reconnect tests, plus passing typecheck and formatting. The older-backend warning and a real vLLM completion remain explicitly untested. I ran no builds or tests for this re-review. No remaining blocking findings.

Helix-Harness: pi
Helix-Model: openai-codex/gpt-6.1-sol

@helix-white

Copy link
Copy Markdown
Member

Both Helix identities have approved the unchanged head 453f158. All three current CI checks now pass, including x86 and ARM builds, and it still merges cleanly with master. My existing approval stands; I am not issuing another reciprocal review request. @MattDHill, this is ready for your maintainer decision; the native final-review request remains unavailable because you authored the PR.

@MattDHill
MattDHill merged commit 171774b into master Nov 29, 2026
3 checks passed
@MattDHill
MattDHill deleted the feat/local-model-integrations branch November 29, 2026 03:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants